<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>ES10-数组方法扩展flat flatMap</title>
</head>
<body>
  <script>
    // flat 将多维数组转化为低维数组
    const arr=[1,2,3,[5,6]]//二维数组
    console.log(arr.flat());
    const arr1=[1,2,3,[5,6,[7,8,9]]]//二维数组
    // flat中的参数表示展开的层级，默认为1,三维数组转化为一维数组，展开两次
    console.log(arr1.flat(2));

    // flatMap 将返回的多维数组转化为低维数组
    const arr2=[1,2,3,4,5]
    const res=arr2.flatMap(item=>[item*10])
    console.log(res);
  </script>
</body>
</html>